package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * 通常Controller组件的类名XXXController
 */
@Controller
public class HelloController {

    //返回值为ModelAndView这种方式不重要
    @RequestMapping("hello1")
    public ModelAndView hello1() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/hello.jsp");
        return modelAndView;
    }

    //如果Handler方法要响应Json，一定要包含@ResponseBody
    //如果不包含@ResponseBody，默认作为ModelAndView来处理
    @ResponseBody
    @RequestMapping("hello2")
    public String hello2() {
        return "hello world";
    }
}
